package com.ruoyi.web.controller.gis;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.gis.domain.PollutionsourceGisVO;
import com.ruoyi.gis.service.PollutionsourceGisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/gis/pollutionsource")
public class PollutionsourceGisController extends BaseController {

    @Autowired
    private PollutionsourceGisService pollutionsourceGisService;

    /**
     * 污染源信息撒点
     */
    @GetMapping("/pollutionsourceInfo")
    public AjaxResult getPollutionsourceInfo(PollutionsourceGisVO vo) {
        List<Map<String, Object>> list = pollutionsourceGisService.getPollutionsourceInfo(vo);
        return AjaxResult.success(list);
    }

    /**
     * 在线污染源实时数据
     */
    @GetMapping("/pollutionsourceRealTimeData")
    public AjaxResult getPollutionsourceRealTimeData(PollutionsourceGisVO vo) {
        List<Map<String, Object>> map = pollutionsourceGisService.getPollutionsourceRealTimeData(vo);
        return AjaxResult.success(map);
    }


    /**
     * 查询污染源对应排口
     *
     * @Param [pollutionsourceId] 污染源id
     * outPutType 排口类型 2进 1出 默认 1出水口
     **/
    @GetMapping("/pollutionsourceWateroutput")
    public AjaxResult pollutionsourceWateroutput(PollutionsourceGisVO vo) {
        if (!StringUtils.isNotEmpty(vo.getOutPutType())) {
            vo.setOutPutType("1");
        }
        List<Map<String, Object>> list = pollutionsourceGisService.pollutionsourceWateroutput(vo);

        return AjaxResult.success(list);
    }

    /**
     * 在线污染源监测因子趋势
     */
    @GetMapping("/pollutionsourceItemTrend")
    public AjaxResult getPollutionsourceTrend(PollutionsourceGisVO vo) {
        Map<String, Object> map = pollutionsourceGisService.pollutionsourceItemTrend(vo);
        return AjaxResult.success(map);
    }

    /**
    获取污染源企业类型
     */
    @GetMapping("/pollutionsourceenterprisetype")
    public AjaxResult pollutionsourceenterprisetype() {

        List<Map<String, Object>> list = pollutionsourceGisService.pollutionsourceenterprisetype();
        return AjaxResult.success(list);
    }

    /**
     * 获取污染源企业在线监测最新达标率
     */
    @GetMapping("/enterprisemonitorrate")
    public AjaxResult getEnterpriseMonitorRate() {
        Map<String, Object> list = pollutionsourceGisService.getEnterpriseMonitorRate();
        return AjaxResult.success(list);
    }

    /**
     * 获取污染源最近12个月的数据
     */
    @GetMapping("/basPollutionsourcewrwpfl")
    public Map<String, Object> dcBasPollutionsourcewrwpfl() {
        Map pollutionsourcewaterhourdatasize = pollutionsourceGisService.BasPollutionsourcewrwpfl();
        Map<String, Object> mapdata = new HashMap<>();
        mapdata.put("data", pollutionsourcewaterhourdatasize);
        mapdata.put("code", 200);
        mapdata.put("msg", "success");
        return mapdata;


    }
}
